<?php
namespace app\admin\controller;

use think\Controller;

class Mros extends Controller
{

    public function bigdata()
    {
        return $this->fetch('');
    }

    public function maintain()
    {
        return $this->fetch('');
    }

    public function params()
    {
        $data = mro_get();
        $this->assign('data',json_encode($data));
        return $this->fetch('');
    }

    public function contents_submit()
    {
        $name = input('name');
        $value = input('value');

        $s = mro_set($name,$value);

        if($s){
            return js_return(1,'success');
        }
        return js_return(0,'error');

    }

    public function apimro()
    {
        header('Access-Control-Allow-Origin:*');
        $mro = mro_get();
        $response = [];
        switch (input('type')) {

            case 'user_active':
                $response[] = [
                    'aims' => $mro['users_total'],
                    'actual' => $mro['users_active'],
                ];
                break;

            case 'product_use':
                $response[] = [
                    'aims' => $mro['products_total'],
                    'actual' => $mro['products_use'],
                ];
                break;

            case 'city_cover':
                $response[] = [
                    'aims' => $mro['citys_total'],
                    'actual' => $mro['citys_cover'],
                ];
                break;
            case 'cover':
                $response[] = [
                    'aims' => $mro['citys_total'],
                    'actual' => $mro['citys_cover'],
                ];
                break;
            case 'earth':
                $response = [
                [
      "lat"=> 37.77,
    "lng"=> -122.41
  ],
  [
      "lat"=> 37.56,
    "lng"=> -77.42
  ],
  [
      "lat"=> 50.1,
    "lng"=> 8.63
  ],
  [
      "lat"=> 1.58,
    "lng"=> 103.79
  ],
  [
      "lat"=> 22.27,
    "lng"=> 114.16
  ],
  [
      "lat"=> 39.9,
    "lng"=> 116.4
  ],
  [
      "lat"=> 31.23,
    "lng"=> 121.47
  ],
  [
      "lat"=> 35.17,
    "lng"=> 134.03
  ],
  [
      "lat"=> -35.38,
    "lng"=> 149.25
  ]
];
                break;

            case 'user_total':
                $response[] = [
                    'name' => "",
                    'value' => $mro['users_total'],
                ];
                break;
            case 'company_toal':
                $response[] = [
                    'name' => "",
                    'value' => $mro['companys_total'],
                ];
                break;
            case 'machine_use':
                $response[] = [
                    'name' => "",
                    'value' => $mro['machines_use'],
                ];
                break;
            case 'income_total':
                $response[] = [
                    'name' => "",
                    'value' => $mro['income_total'],
                ];
                break;
                
            case 'income_year':
                $response =
                    [
  [
      "x"=> "2010/01/01 00:00:00",
    "y"=> 105672,
    "s"=> "1"
  ],
  [
      "x"=> "2010/01/01 00:00:00",
    "y"=> 113250,
    "s"=> "2"
  ],
  [
      "x"=> "2010/02/01 00:00:00",
    "y"=> 142351,
    "s"=> "1"
  ],
  [
      "x"=> "2010/02/01 00:00:00",
    "y"=> 134522,
    "s"=> "2"
  ],
  [
      "x"=> "2010/03/01 00:00:00",
    "y"=> 132532,
    "s"=> "1"
  ],
  [
      "x"=> "2010/03/01 00:00:00",
    "y"=> 234230,
    "s"=> "2"
  ],
  [
      "x"=> "2010/04/01 00:00:00",
    "y"=> 124230,
    "s"=> "1"
  ],
  [
      "x"=> "2010/04/01 00:00:00",
    "y"=> 123120,
    "s"=> "2"
  ],
  [
      "x"=> "2010/05/01 00:00:00",
    "y"=> 234523,
    "s"=> "1"
  ],
  [
      "x"=> "2010/05/01 00:00:00",
    "y"=> 323445,
    "s"=> "2"
  ]
];
        }

        return json($response);


    }



}
